package com.yocard.yxyd.ui.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.yocard.yxyd.R;

/**
 * Created on 2019/4/15.
 */
public class ViewOrderDetail extends FrameLayout {

    private final String leftText;
    private final String rightText;
    private int colorId = -1;

    public ViewOrderDetail(@NonNull Context context, String leftText, String rightText) {
        super(context);
        this.leftText = leftText;
        this.rightText = rightText;
        init();
    }

    public ViewOrderDetail(@NonNull Context context, String leftText, String rightText, int colorId) {
        super(context);
        this.leftText = leftText;
        this.rightText = rightText;
        this.colorId = colorId;
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.item_order_detail, this);
        TextView tvLeft = findViewById(R.id.tv_left);
        TextView tvRight = findViewById(R.id.tv_right);
        tvLeft.setText(leftText);
        tvRight.setText(rightText);
        if(colorId == -1) return;
        tvRight.setTextColor(getContext().getResources().getColor(colorId));
    }

}
